package com.omi.iberolactalpreventa.objects;

import java.util.ArrayList;

import com.omi.iberolactalpreventa.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdapterResumen extends BaseAdapter{
	
	Activity activity;
	ArrayList<itmResumen> items;
	
	public AdapterResumen(Activity activity, ArrayList<itmResumen> items) {
		this.activity = activity;
		this.items = items;
	}

	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		return items.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View v = convertView;
		
		if(convertView==null)
		{
			LayoutInflater inf = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = inf.inflate(R.layout.item_resumen, null);
		}
		
		itmResumen itm = items.get(position);
		
		TextView txtresumDesc = (TextView) v.findViewById(R.id.txtresumDesc);
		txtresumDesc.setText(itm.getDescripcion());
		
		TextView txtResumCant = (TextView) v.findViewById(R.id.txtResumCant);
		txtResumCant.setText(itm.getCantidad());
		
		TextView txtResumPrecio = (TextView) v.findViewById(R.id.txtResumPrecio);
		txtResumPrecio.setText(itm.getPrecio());
		
		TextView txtResumImpLinea = (TextView) v.findViewById(R.id.txtResumImpLinea);
		txtResumImpLinea.setText(itm.getImporte_linea());
		
		return v;
	}

}
